const path=require('path')
const fs= require('fs')



let nr= process.argv.slice(2)

//判断length
if(nr.length==0)
{
    dx(process.cwd())//返回当前
}
else{
    //传入参数的
    dx(path.join(process.cwd(),nr[0].slice(1)))
}
function dx(url)
{
    let childpath=fs.readdirSync(url)
    //遍历每一项
    childpath.forEach((item)=>
    {
        let childrenpath=path.join(url,item)
        //判断是否是文件或者文件夹
        if(fs.statSync(childrenpath).isDirectory())
        {
            //文件夹
            dx(childrenpath)
        }
        else{
            let gs=path.extname(item).slice(1)
            let {size}=fs.statSync(childrenpath)
            process.stdout.write(`${item}———${gs}———${size}\n`);
        }
    })
}